#include <bits/stdc++.h>
using namespace std;
struct car{
    long double v,d,a;
    bool isOsp=false;
};
long double socp(long double st,long double v,long double a,long double to){
    long double s=to-st;
    return sqrt(v*v+2*a*s)*1.00;
}
void solve(){
    set<int> ds;
    int n,m,l;
    long double vl;
    cin>>n>>m>>l>>vl;
    car crs[100005];
    long double dt[100005];
    for (int i=0;i<n;i++){
        cin>>crs[i].d>>crs[i].v>>crs[i].a;
    }
    for (int i=0;i<m;i++){
        cin>>dt[i];
    }
    int osc=0;
    for (int i=0;i<n;i++){
        if (crs[i].v<=vl&&crs[i].a==0){
            continue;
        }

        for (int j=m;j>=0;j--){
            if (crs[i].d>dt[j])continue;
            long double now=crs[i].d;
            long double spd=socp(now,crs[i].v,crs[i].a,dt[j]);

            if (spd>vl){
                osc++;
                //cout<<"dt[j]  "<<dt[j]<<" "<<spd<<" i: "<<i<<endl;
                ds.insert(dt[j]);
                break;
            }

        }
    }

    cout<<osc<<" "<<m-ds.size()<<" "<<ds.size()<<endl;
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while (t--){
        solve();
    }
    return 0;
}
